﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CamShared
{
    public partial class Input : Form
    {
        public Input(string label, string text, string title)
        {
            InitializeComponent();
            lbl.Text = label;
            this.Text = title;

            if (text.ToUpper() == "YES" || text.ToUpper() == "NO")
            {
                cboBool.Visible = true;
                txt.Visible = false;

                cboBool.SelectedIndex = text.ToUpper() == "YES" ? 0 : 1;
            }
            else
            {
                txt.Text = text;
                txt.SelectAll();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        public string TextValue
        {
            get {
                if (cboBool.Text == "")
                {
                    return txt.Text;
                }
                else
                {
                    return cboBool.Text;
                }
            }
        }

        private void txt_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnOK_Click(null, null);
            }
        }

    }
}
